package com.newstart.springdatajpa.project.model.entity;

import lombok.Data;
import org.hibernate.annotations.CreationTimestamp;
import org.hibernate.annotations.UpdateTimestamp;

import javax.persistence.*;
import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Objects;

@Entity
@Data
public class Project implements Serializable {
    private int id;
    private String projectName;
    private Timestamp createTime;
    private Timestamp updateTime;
    private Integer projectUse;

    @Id
    @Column(name = "id")
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    public int getId() {
        return id;
    }

    public void setId(int id) {
        this.id = id;
    }

    @Basic
    @Column(name = "project_name")
    public String getProjectName() {
        return projectName;
    }

    public void setProjectName(String projectName) {
        this.projectName = projectName;
    }

    @Basic
    @Column(name = "create_time")
    @CreationTimestamp
    public Timestamp getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Timestamp createTime) {
        this.createTime = createTime;
    }

    @Basic
    @Column(name = "update_time")
    @UpdateTimestamp
    public Timestamp getUpdateTime() {
        return updateTime;
    }

    public void setUpdateTime(Timestamp updateTime) {
        this.updateTime = updateTime;
    }

    @Basic
    @Column(name = "project_use")
    public Integer getProjectUse() {
        return projectUse;
    }

    public void setProjectUse(Integer projectUse) {
        this.projectUse = projectUse;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Project project = (Project) o;
        return id == project.id &&
                Objects.equals(projectName, project.projectName) &&
                Objects.equals(createTime, project.createTime) &&
                Objects.equals(updateTime, project.updateTime) &&
                Objects.equals(projectUse, project.projectUse);
    }

    @Override
    public int hashCode() {
        return Objects.hash(id, projectName, createTime, updateTime, projectUse);
    }

}
